package com.boomsecret.comparable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author wangjinliang on 2018/12/6.
 */
public class ComparableDemo {
    public static void main(String[] args) {
        List<UserAsc> userAscList = new ArrayList<>();
        userAscList.add(new UserAsc("a", 12));
        userAscList.add(new UserAsc("b", 12));
        userAscList.add(new UserAsc("c", 20));
        userAscList.add(new UserAsc("d", 2));

        // asc
        Collections.sort(userAscList);
        System.out.println(userAscList.toString());

        List<UserDesc> userDescList = new ArrayList<>();
        userDescList.add(new UserDesc("a", 12));
        userDescList.add(new UserDesc("b", 12));
        userDescList.add(new UserDesc("c", 20));
        userDescList.add(new UserDesc("d", 2));

        // desc
        Collections.sort(userDescList);
        System.out.println(userDescList.toString());
    }
}
